package com.qjs.smterp.services;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qjs.smterp.model.Users;
import com.qjs.smterp.jpa.UserDao;


@Service("securityServices")
@Transactional
public class SecurityServicesImpl implements SecurityServices {

	private static final long serialVersionUID = 1L;
	@Resource(name="userDao")
	private UserDao userDao;

	@Override
	public Users findUsers(String userName, String password) {
		return userDao.findByUserNameAndPass(userName, password);
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public List<Users> findAll() {
		return userDao.getList();
	}

	public void updateUsers(Users user) {
		userDao.save(user);
	}

	@Override
	public void delete(Users user) {
		userDao.delete(user);

	}

	@Override
	public Users findUsers(String userName) {	
		return userDao.findByUserName(userName);
	}

	

}
